package com.anmory;

import org.junit.jupiter.api.Test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class jdbctest {
    @Test
    public void JdbcTest() throws ClassNotFoundException, SQLException {
        // 1. 注册驱动
        Class.forName("com.mysql.jdbc.Driver");
        // 2. 创建连接
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "lmjnb666");
        // 3. 创建语句集
        Statement statement =connection.createStatement();
        // 4. 执行语句集
        int i = statement.executeUpdate("UPDATE user SET age = 100 WHERE id = 3");
        System.out.println(i);
        // 5. 关闭连接
        statement.close();
        connection.close();
    }
}
